home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 22 code / PCI Driver Sample / NCR_DriverProject / Src / PublishDriverDebugInfo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-19  |  2.5 KB  |  70 lines  |  [TEXT/MPCC]

  1. /*                                    PublishDriverDebugInfo.c                            */
  2. /*
  3.  * PublishDriverDebugInfo.c
  4.  * Copyright © 1994-95 Apple Computer Inc. All rights reserved.
  5.  *
  6.  */
  7. /*    .___________________________________________________________________________________.
  8.       | This function shows how to store a private property into the Name Registry,        |
  9.       | replacing any existing instance of this property. The property contains a pointer    |
  10.       | to the driver globals, which a test application may use for debugging.             |
  11.     .___________________________________________________________________________________.
  12. */
  13.  
  14. #include "NCRDriverPrivate.h" 
  15.  
  16. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  17.  * Store a private property into the name registry with a pointer to our globals. The
  18.  * test function (or MacsBug) can use this for debugging. Errors are logged and ignored.
  19.  */
  20. void
  21. PublishDriverDebugInfo(void)
  22. {
  23.         OSErr                    status;
  24.         DriverGlobalPtr            driverGlobalPtr;
  25.         RegPropertyValueSize    size;
  26.  
  27.         Trace(PublishDriverDebugInfo);
  28.         /*
  29.          * Globalize the script so that the test driver can locate it using the
  30.          * Name Registry.
  31.          */
  32.         GLOBAL.ncrSCSIScript = gNCRSCSIScript;
  33.         GLOBAL.ncrSCSIScriptSize = gNCRSCSIScriptSize;
  34.         driverGlobalPtr = &GLOBAL;
  35.         /*
  36.          * Does the property currently exist (with the correct size)?
  37.          */
  38.         status = RegistryPropertyGetSize(        /* returns noErr if the property exists    */
  39.                     &GLOBAL.deviceEntry,
  40.                     kDriverGlobalsPropertyName,
  41.                     &size
  42.                 );
  43.         if (status == noErr) {
  44.             /*
  45.              * Replace the current value of the property with its new value. In this
  46.              * example, we are replacing the entire value and, potentially, changing
  47.              * its size. In production software, you may need to read an existing
  48.              * property and modify its contents. This shouldn't be too hard to do.
  49.              */
  50.             status = RegistryPropertySet(        /* Update existing value                */
  51.                         &GLOBAL.deviceEntry,                    /* RegEntryID            */
  52.                         kDriverGlobalsPropertyName,                /* Property name        */
  53.                         (RegPropertyValue *) &driverGlobalPtr,    /* -> Property contents    */
  54.                         sizeof driverGlobalPtr                    /* Property size        */
  55.                     );
  56.             CheckStatus(status, "\pPublishDebugInfo - RegistryPropertySet");
  57.         }
  58.         else {
  59.             status = RegistryPropertyCreate(    /* Make a new property                    */
  60.                         &GLOBAL.deviceEntry,                    /* RegEntryID            */
  61.                         kDriverGlobalsPropertyName,                /* Property name        */
  62.                         (RegPropertyValue *) &driverGlobalPtr,    /* -> Property contents    */
  63.                         sizeof driverGlobalPtr                    /* Property size        */
  64.                     );
  65.             CheckStatus(status, "\pPublishDebugInfo - RegistryPropertyCreate");
  66.         }
  67. }
  68.  
  69.  
  70.